<template>
    <div class="search">
        <el-card>
            <el-input v-model="keyword" :placeholder="placeholderText" size="small"></el-input>
            <el-button size="small" plain @click="search">查询</el-button>
            <el-button type="warning" size="small" plain @click="reset">重置</el-button>
        </el-card>
    </div>
</template>
<script>
export default {
    name: 'Search',
    components: {

    },
    mixins: [],
    props: ['placeholder'],
    data() {
        return {
            keyword: '',
            type: null,
            placeholderText: this.placeholder || '请输入关键字查询'
        }
    },
    computed: {

    },
    watch: {

    },
    mounted() {
        this.getType()
    },
    methods: {
        search() {
            const obj = {
                keyword: this.keyword,
                currentPage: 1,
                pageSize: 10,
                type: this.type
            }
            this.$emit('searchData', obj)
        },
        reset() {
            this.keyword = ''
            this.$emit('resetData')
        },
        getType() {
            if (this.$route.fullPath == '/information') {
                this.type = 0
            } else if (this.$route.fullPath == '/policy') {
                this.type = 1
            }
        }
    }
};
</script>
<style lang='less' scoped>
.search {
    margin-bottom: 5px;

    .el-input {
        width: 200px;
    }

    .el-button--default.is-plain {
        color: #6e77f2;
        background: #f1f1fe;
        border-color: #c5c9fa;
        margin-left: 10px;

    }

    .el-button--default.is-plain:hover {
        color: white;
        background-color: #6e77f2;
    }
}
</style>